package cn.org.timespace.ons.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.org.timespace.ons.util.pager.Pager;


public class TSBaseDAO extends HibernateDaoSupport{
	
public static Log log = LogFactory.getLog(TSBaseDAO.class);
	
	
	protected void setQueryPager(Query query,Pager p){
		query.setFirstResult((p.getCurrentPageNum() - 1)*p.getItemPerPage());
		query.setMaxResults(p.getItemPerPage());		
	}
	
	protected void closeSessionAndQuery(Session session,Query query){
		if(session != null) session.close();
		if(query != null) query = null;	
	}

}
